package com.blacktry.controller.blog;


import com.blacktry.entity.enums.OprLogConst;
import com.blacktry.entity.model.vueVO.Option;
import com.blacktry.service.SortsService;
import com.blacktry.utils.log.OperLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author blackTry
 * @since 2022-02-07
 */
@Api(value="分类模块", tags = "分类管理接口")
@RestController
@RequestMapping("/sorts")
public class SortsController {

    @Autowired
    private SortsService sortsService;

    @OperLog(operModul = "分类管理-查看分类列表",operType = OprLogConst.SELECT,operDesc = "查看分类列表")
    @ApiOperation("查看分类列表")
    @GetMapping("/selectSortOptions")
    public List<Option> selectSortOptions(){
        return sortsService.selectSortOptions();
    }

    @OperLog(operModul = "分类管理-查看某个博客的分类列表",operType = OprLogConst.SELECT,operDesc = "查看某个博客的分类列表")
    @ApiOperation("查看某个博客的分类列表")
    @GetMapping("/selectOneSortOptions/{id}")
    public List<Option> selectOneSortOptions(@PathVariable("id")String id){
        return sortsService.selectOneSortOptions(id);
    }

    @OperLog(operModul = "分类管理-某个博客回显分类列表",operType = OprLogConst.SELECT,operDesc = "某个博客回显分类列表")
    @ApiOperation("某个博客回显分类列表")
    @GetMapping("/backOneSortOptions/{id}")
    public String[] backOneSortOptions(@PathVariable("id")String id){
        return sortsService.backOneSortOptions(id);
    }


}

